using System;
using System.Collections.Generic;
using System.Text;

namespace Intergr8.IO.File
{
    public class FileIOBase
    {
        private string _workingDir = "";
        private string _fileName = "";

        /// <summary>
        /// Default constructor
        /// </summary>
        public FileIOBase()
        {
            this._fileName = "";
            this._workingDir = "";
        }

        /// <summary>
        /// Constructor with fully qualified path and filename
        /// </summary>
        /// <param name="fullpath"></param>
        public FileIOBase(string fullpath)
        {
            this._fileName = System.IO.Path.GetFileName(fullpath);
            this._workingDir = System.IO.Path.GetDirectoryName(fullpath);
        }

        /// <summary>
        /// Public constructor with individual path and filename
        /// </summary>
        /// <param name="workingDir"></param>
        /// <param name="fileName"></param>
        public FileIOBase(string workingDir, string fileName)
        {
            this._fileName = fileName;
            this._workingDir = workingDir;
        }

        /// <summary>
        /// The path ofthe Working Directory where all files will be processed
        /// </summary>
        public string WorkingDirectory
        {
            get { return _workingDir; }
            set { _workingDir = value; }
        }

        /// <summary>
        /// The Filename of the file to be processed
        /// </summary>
        public string FileName
        {
            get { return _fileName; }
            set { _fileName = value; }
        }

        /// <summary>
        /// Flag that the FileIO class is initialised
        /// </summary>
        /// <returns></returns>
        protected bool IsValid()
        {
            if (this._workingDir.Length == 0)
                throw new Exception("The FileIO object is not initialised with a Working Directory");

            if (this._fileName.Length == 0)
                throw new Exception("The FileIO object is not initialised with a Filename");

            return true;
        }

  
    }
}
